package com.ling.springboottest.entity;

import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

@Entity //Entity属性使实体类与表进行绑定。绑定是根据表名与类名的映射关系。类名首字母小写=表名
@Data //自动生成getter、setter、equals、hashCode和toString等等
public class Book {
    //id注解指的是主键。后台设置自增，id-entity
    //IdentifierGenerationException: ids for this class must be manually assigned before calling save():
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    //属性名与字段名进行对应。需要什么字段就写什么属性。目前只取了前3个字段
    private String name;
    private String author;

}
